package com.example.mapper;

import com.example.entity.Books;
import com.example.entity.Student;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author： wzz
 * @date： 2021-07-28 18:06
 */


public interface StudentMapper {

    @Select("select loginTime from students where num=#{num}")
    String getSLoginTime(String num);

    Integer AddStudent(Student student);

    @Select("select password from students where num=#{num}")
    String getSPassword(String num);
    /**
     * 更新最后一次登录时间
     * @param loginTime
     * @return
     */
    int updateLoginTime(String loginTime, String studentNumber);


    @Update("update students set password=#{password} where num=#{num}")
    int updatePassword(String num, String password);

    /**
     * 查询所有的学生信息
     * @return
     */
    List<Student> queryAll();

    /**
     * 查询教师所授课程的学生
     * @param num
     * @return
     */
    List<Student> queryMy(String num);


    int importStudent(List<Student> studentList);

    /**
     * 查询所有班级
     * @return
     */
    List<String> queryClasses();

    List<String> queryMyClass(String num);

    /**
     * 根据条件查询
     * @param studentNumber
     * @param name
     * @param classes
     * @return
     */
    List<Student> conditionSearch(String studentNumber, String name, String classes);

    /**
     * 根据学号查询学生信息
     * @param studentNumber
     * @return
     */
    @Select("select * from students where num=#{studentNumber} and del=0")
    @Results(value = {
            @Result(column = "num",property = "num"),
            @Result(column = "name",property = "name"),
            @Result(column = "sex",property = "sex"),
            @Result(column = "classes",property = "classes"),
            @Result(column = "phone",property = "phone"),
            @Result(column = "loginTime",property = "loginTime"),
    })
    Student queryOne(String studentNumber);

    /**
     * 修改学生信息
     * @param student
     * @return
     */
    int updateStudent(Student student);

    /**
     * 删除学生信息
     * @param studentNumber
     * @return
     */
    int delStudent(String studentNumber);

    /**
     * 获取这个老师所授课的所有班级
     * @param jobNumber
     * @return
     */
    List<String> getCla(String jobNumber);


    List<Books> GetStuBook(String stu_num);

}
